$(document).ready(function() {
	
	$( "#lecturerId" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: "/admin/searchLecturerInfoAjax.html",
				dataType: "json",
				data: {
					q: $("#lecturerId").val()
				},
				success: function( data ) {
					response( $.map( data, function( item ) {
						return {
							label: item.lecturerId + " - " + item.lecturerName + " - " + item.lecturerDepartment,
							value: item.lecturerId
						}
					}));
				}
			});
		},
		minLength: 1
	});
	
	$( "#subjectId" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: "/searchSubjectInfoAjax.html",
				dataType: "json",
				data: {
					q: $("#subjectId").val()
				},
				success: function( data ) {
					response( $.map( data, function( item ) {
						return {
							label: item.subjectId + " - " + item.subjectName,
							value: item.subjectId
						}
					}));
				}
			});
		},
		minLength: 1
	});
});